//===============================================================================
// Microsoft patterns & practices
// Guidance Explorer Offline Client
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================



using System;
using System.Windows.Forms;
using GuidanceExplorer.Model;
//using GuidanceExplorer.Views;

namespace GuidanceExplorer.Controls
{
    /// <summary>
    /// Represents a column in the list view that is linked to the model.
    /// </summary>
    public class ListViewColumn : ColumnHeader
    {
        /// <summary>
        /// Factory
        /// </summary>
        /// <returns></returns>
        public static ListViewColumn New()
        {
            return new ListViewColumn();
        }

        /// <summary>
        /// The column in the model.
        /// </summary>
        private Column _column;

        /// <summary>
        /// Private default constructor.
        /// </summary>
        private ListViewColumn() { }

        /// <summary>
        /// The column in the model.
        /// </summary>
        public Column Column
        {
            get { return _column; }
            set { _column = value; }
        }

        public void SetImage(IntPtr headerhWnd, int imageIdx)
        {
            Win32.HDITEM hd = new Win32.HDITEM();
            hd.mask = Win32.HDI_IMAGE | Win32.HDI_FORMAT;
            hd.fmt = Win32.HDF_LEFT | Win32.HDF_STRING | Win32.HDF_BITMAP_ON_RIGHT | Win32.HDF_IMAGE;
            hd.iImage = imageIdx;

            //Send the message to the column
            Win32.SendMessage(headerhWnd, Win32.HDM_SETITEM, new IntPtr(Index), ref hd);
        }
    }
}

